package com.sunny.design.strategy.exam1;

/**
 * @author Sunny
 * @date 2020/1/4 19:37
 */
public class PromotionStrategyTest {

    public static void main(String[] args) {
//        mode1();
        mode2("COUPON");
    }

    /**
     * 简单实现
     */
    public static void mode1() {
        PromotionActivity coupon = new PromotionActivity(new CouponStrategy());
        PromotionActivity cashBack = new PromotionActivity(new CashBackStrategy());
        coupon.execute();
        cashBack.execute();
    }

    /**
     * 通过工厂模式获取活动类执行相应逻辑
     *
     * @param promotionKey 活动key
     */
    public static void mode2(String promotionKey) {
        PromotionStrategy promotionStrategy = PromotionStrategyFactory.getPromotionStrategy(promotionKey);
        PromotionActivity promotionActivity = new PromotionActivity(promotionStrategy);
        promotionActivity.execute();
    }
}
